{% extends "base.html" %}
{% block page_title %}myAlarm{% endblock %}

{% block content %} 
	<ul id="nav">
	  <li><a href="/defence/" title="My Alarms">My Alarms</a><span>/</span></li>
	  <li><a href="/defence/myPrefix" title="My Prefixs">My Prefixs</a><span>/</span></li>
	  <li><a href="/defence/myASN" title="My ASNs">My ASNs</a><span>/</span></li>
	  <li><a href="/account/profile/" title="My Account">My Account</a><span>/</span></li>
	</ul><!--end nav--><!-- class="current" class="anews"-->
	
  <div id="featured-projects">
    <h4 align="center">My Alarms</h4>
    <div>
      <form action="/alarms/" method="post">{% csrf_token %}
        <table><tr>
          <td>
            <input type="submit" value="filter">
          </td>
          <td>
            #alarms: {{ form.topx }}<br/>
            {% if form.topx.errors %}
              <font color="red">int: [1, 99]</font>
            {% endif %}
          </td>
          <td>
            fingerprint range: from {{ form.fig_low }} to {{ form.fig_high }}<br/>
            {% if form.fig_low.errors %}
              <font color="red">float: [-1.0, 1.0]</font>
            {% else %}
              {% if form.fig_high.errors %}
                <font color="red">float: [-1.0, 1.0]</font>
              {% endif %}
            {% endif %}
          </td>
          <td>
            alarm lasts: {{ form.fig_last }} seconds<br/>
            {% if form.fig_last.errors %}
              <font color="red">int: [1, 120]</font>
            {% endif %}
          </td>
          <td>
            prefix: {{ form.prefix }}<br/>
            {% if form.prefix.errors %}
              <font color="red">
                IPv4: A.B.C.D/M (0&le;M&le;32),<br/>
                IPv6: A:B:C::/M (0&le;M&le;128)
              </font>
            {% endif %}
          </td>
          <td>
            AS: {{ form.AS }}<br/>
            {% if form.AS.errors %}
              <font color="red">int: [1, 2^32]</font>
            {% endif %}
          </td><!--
          <td>
            RPKI: {{ form.rpki }}<br/>
            {% if form.rpki.errors %}<font color="red">Y/N</font>{% endif %}
          </td>-->
        </tr></table>
      </form>
    </div>
    <br/>
    <table>
      <tr><td>
        <table>
          <head><tr><th>#</th></tr></head>
          <body>{% for alarm in alarms %}<tr><td align=right>{{ forloop.counter }}</td></tr>{% endfor %}</body>
        </table>
      </td>
      <td>
        <table id="alarms" class="tablesorter">
          <thead>
            <tr>
              <th>Time (UTC)</th>
              <!--<th>Timestamp</th>-->
              <th>IP Prefix</th>
              <th>CC</th>
              <th>Suspicious AS Path Segment</th>
              <!-- <th>Alarm Delay(s)</th>
              <th>Alarm Lasts(s)</th>
              <th>Avg. Fing.</th> -->
              <!--<th>RPKI</th>-->
              <th>Detail</th>
            </tr>
          </thead>
          <tbody>
          {% for alarm in alarms %}
            <tr>
              <td>{{ alarm.1 }}</td>
              <!--<td>{{ alarm.0.time }}</td>-->
              <td>
                <a href="http://bgp.he.net/net/{{ alarm.0.prefix_dec }}" target="_blank">{{ alarm.0.prefix_dec }}</a>
               {% if alarm.5 %}<a href="/fingerprints/{{ alarm.0.alarm_id }}#prefixes" target="_blank">+{{ alarm.5 }}</a>
               {% endif %}
              </td>
              <td>{{ alarm.6 }}</td>
              <td align=right>
                {% if alarm.0.homeas %}
                Origin change: {% if alarm.0.oldhomeas %}<a href="http://bgp.he.net/AS{{ alarm.0.oldhomeas }}#_prefixes" target="_blank">AS{{ alarm.0.oldhomeas }}</a>{% else %}N/A{% endif %}
                -&gt; <a href="http://bgp.he.net/AS{{ alarm.0.homeas }}#_prefixes" target="_blank">AS{{ alarm.0.homeas }}</a>
                {% else %}
                  {% if alarm.2 %}AS triple:
                <a href="http://bgp.he.net/AS{{ alarm.2 }}#_graph4" target="_blank">AS{{ alarm.2 }}</a>
                  {% else %}AS edge:
                  {% endif %}
                <a href="http://bgp.he.net/AS{{ alarm.3 }}#_graph4" target="_blank">AS{{ alarm.3 }}</a>
                <a href="http://bgp.he.net/AS{{ alarm.4 }}#_graph4" target="_blank">AS{{ alarm.4 }}</a>
                {% endif %}
              </td>
              <!-- <td align=right>{{ alarm.2 }}</td>
              <td align=right>{{ alarm.3 }}</td>
              <td align=right>{{ alarm.4 }}</td> -->
              <!--<td align=right>{{ alarm.0.rpki }}</td>-->
              <td><a href="/fingerprints/{{ alarm.0.alarm_id }}" target="_blank">>>></a></td>
            </tr>
          {% endfor %}
          </tbody>
        </table>
      </td></tr>
    </table>
  </div><!--end featured-projects-->
{% endblock %}
{% block js_script %}
  <script src="/static/jquery-latest.js"></script>
  <script type="text/javascript" src="/static/jquery.tablesorter.js"></script>
  <script type="text/javascript">
    $(document).ready(function(){ 
        $("#alarms").tablesorter();
      }
    );
  </script>
{% endblock %}
